package com.qf.controller;

import com.qf.pojo.resp.BaseResp;
import com.qf.service.ShopCartService;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/shopCart")
public class ShopCartController {

    @Autowired
    ShopCartService shopCartService;

    @RequestMapping("/addShopCart")
    public BaseResp addShopCart(@RequestBody Map map, HttpServletRequest request){
        return shopCartService.addShopCart((Integer)map.get("dishesId"),request);
    }

    @RequestMapping("/findShopCart")
    public BaseResp findShopCart(HttpServletRequest request){
        return shopCartService.findShopCart(request);
    }

    @RequestMapping("/removeShopCart")
    public BaseResp removeShopCart(HttpServletRequest request){
        return shopCartService.removeShopCart(request);
    }

    @RequestMapping("/delShopCart")
    public BaseResp delShopCart(@RequestBody Map map, HttpServletRequest request){
        return shopCartService.delShopCart((Integer)map.get("dishesId"),request);
    }
}
